<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-01 10:57
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Transformers;


use League\Fractal\TransformerAbstract;

class StoreBarberListTransformer extends TransformerAbstract
{
	private $list;
	public function __construct($userList)
	{
		$this->list = $userList;
	}

	public function transform(){
		$result = $this->list;
		if(!empty($result['items'])) {
			$result['items'] = array_map(function ($v) {
				return [
					'id'       => $v['id'],
					'name'     => $v['nick'],
					'portrait' => $v['image'],
					'salary'   => empty($v['salary']) ? 0 : $v['salary'],
					'is_boss'  => $v['is_boss'],
					'add_time' => date('Y-m-d',strtotime($v['created_time']))
				];
			}, $this->list['items']);
		}
		return $result;
	}

}